<?php
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Operation.php");						//--> Operation
include_once("ShippingFee.php");					//--> ShippingFee
require_once("controlHeader.php");					//--> system control header
	

$objOperate		= new Operation($objSession->getLanguage());	//--> Operation
$objShippingFee	= new ShippingFee(DB_TAG_PUBLIC, $uid);			//--> Attributes

$error_message = '';
if(isset($_GET['page']))
	$page = $_GET['page'];
else 
	$page = 1;
	
$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(count($arrOperate) > 0){
	$strQuery = $_SERVER["REQUEST_URI"];
	$arrUrlInfo 	= pathinfo($strQuery);
	$selfFileName	= $arrUrlInfo['filename'];
	
	$arrOperateAllInfo = $objOperate->listFromCustom($arrOperate, " WHERE id in (".implode(",", $arrOperate).") AND name != 'Add'");
	
	$i = 0; 
	foreach($arrOperateAllInfo as $key => $value){
		$strFileName = $selfFileName."_".$value['name'].".php";
		
		if(file_exists($strFileName)){
			$arrOperateInfo[$i]['name'] 		= $value['name'];
			$arrOperateInfo[$i]['viewName'] 	= $value['name'];
			
			$i++;
		}
	}
}

$arrDataList = array();

$arrAllData = $objShippingFee->lists($arrOperate, $where, $order, $page, DISPLAY_DATA_SIZE, '');
foreach($arrAllData as $key => $value){
	$value['type'] 		= $objShippingFee->getColumn(DB_TAG_PUBLIC, "SELECT name FROM shipping_type WHERE id = " . $value['shippingTypeID']);
	$value['method'] 	= $objShippingFee->getColumn(DB_TAG_PUBLIC, "SELECT name FROM shipping_method WHERE id = " . $value['shippingMethodID']);
	
	$value['zone'] 	= $objShippingFee->getColumn(DB_TAG_PUBLIC, "SELECT name FROM zones WHERE id = " . $value['zoneID']);
	
	$arrDataList[] = $value;
}

/*----- out html -----*/
$smarty = new Smarty();		//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = COMPILE_SYS_DIR;

$smarty->assign('error_message', $error_message);
$smarty->assign('backurl',$backurl);

$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);

$smarty->assign('selfFileName', $selfFileName);
$smarty->assign('arrOperateInfo', $arrOperateInfo);

$smarty->assign('arrDataList', $arrDataList);
$smarty->assign('PAGE_BAR', $objShippingFee->pagenav);

$smarty->display('listShippingFee.htm');
?>
